#include "tabbarhorline.h"
#include <QPainter>
#include <QMatrix>
#include "toptabbar.h"

using namespace ExecTerminalImplNS;

const int TAB_BAR_HOR_LINE_HEIGHT = 5;

TabBarHorLine::TabBarHorLine(QWidget * p): QWidget(p),
theTabBar(0)
{
    if (p)
    {
        theTabBar = p->findChild<TopTabBar*>();
    }
    setMinimumHeight(TAB_BAR_HOR_LINE_HEIGHT);
    setMaximumHeight(TAB_BAR_HOR_LINE_HEIGHT);
}

int TabBarHorLine::orientation()const
{
    return theTabBar ? theTabBar->orientation() : UP_ORIENTATION;
}

void TabBarHorLine::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    if (orientation() == DOWN_ORIENTATION)
    {
        QMatrix rotMatrix;
        rotMatrix.translate(width(), height());
        rotMatrix.rotate(180);
        painter.setMatrix(rotMatrix);
    }
    QPixmap lineBackground (":/Resources/top_bg_line.png");
    painter.drawTiledPixmap(0, 0, width(), height(), lineBackground);

}


